package concurrent;

import java.util.concurrent.BlockingQueue;

public class Consumer implements Runnable{

	private final String consumerName;
	private final BlockingQueue<String> queue;
	
	Consumer(String consumerName, BlockingQueue<String> queue){
		this.consumerName = consumerName;
		this.queue = queue;
	}
	
	public void run(){
		for(int i = 0; i < 10; i++){
			try{
				String output = queue.take();
				System.out.println("Output at "+consumerName+" is: "+output);
			}catch(InterruptedException ex){
				ex.printStackTrace();
			}
			
		}
	}
}
